package com.example.a2209_shop.database

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.example.base.entity.ShopEntity

@Dao
interface OrderDao {
    //新增订单
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertOrder(shopEntity: ShopEntity)
    //修改订单状态
    @Update
    fun updateOrder(shopEntity: ShopEntity)
    //查询订单--指定状态的
    @Query("select * from order_info where orderStatus=:status")
    fun queryOrderByStatus(status:Int):List<ShopEntity>
    //查询所有订单
    @Query("select * from order_info")
    fun queryOrder():List<ShopEntity>
    //删除订单
    @Delete
    fun deleteOrder(shopEntity: ShopEntity)
    //举例：删除指定订单的所有商品
    @Query("delete from order_info where order_id = :orderId")
    fun deleteOrders(orderId:Int)

}